#
# Mostly empty base class; has constructors, autoloaders, error handling
#
# 2009, Mike Widner <mikewidner@gmailcom>
#
###########

package Fangcheng;

use 5.006001;
use warnings;
use strict;
use vars qw( $AUTOLOAD @ISA );

use Carp;

# magically set/retrieve values
sub AUTOLOAD {
	my ($self, $value) = @_;
	if (not ref($self)) {
		croak "$self is not an object";
	}
	
	my $name = $AUTOLOAD;
	$name =~ s/^(.*::)+//;
	if (defined $value) {
		$self->{"_$name"} = $value;
	}
	
	return( $self->{"_$name"} );
}

# this is so AUTOLOAD won't get called on DESTROY
sub DESTROY { }

# most of the modules override this; generic constructor
sub new {
	my ($class) = shift;
	my $self = {};
	bless $self, ref($class) || $class;
	return( $self );
}

sub error {
	my ($self, $error) = @_;
	
	# Will modify to save state, reload page for correction
	# but works for testing purposes now
	croak "$error";
	
}


1;